import http from "../utils/http";
// 分类录入
export const categoryPost = (cateObj) => {
  return http.post("classes/ReactCategory", cateObj);
};

//查询分类
export const categoryGet = (all) => {
  let where = all ? {} : { parentId: "0-0" };
  return http.get("classes/ReactCategory", {
    params: {
      where,
    },
  });
};

//课程录入
export const articlePost = (artObj) => {
  return http.post("classes/ReactArticle", artObj);
};

//课程列表
export const articleGet = (condition) => {
  let { name, vip } = condition;
  let where = {};
  if (name) {
    // where.name = name; //精准匹配
    where.name = { $regex: name, $options: "i" }; //正则查询、模糊查询
  }
  let query = JSON.stringify(where);
  return http.get(`classes/ReactArticle?where=${query}`);
};

//测试redux-saga触发异步请求
export const countPost = (count) => {
  return http.post("classes/ReactSaga", { count });
};

export const countPut = (id, count) => {
  return http.put(`classes/ReactSaga/${id}`, { count });
};

export const countGet = () => {
  return http.get("classes/ReactSaga");
};
